home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Astronomy / Moon / Source / MoonIconView.m < prev    next >
Text File  |  1993-01-19  |  1KB  |  55 lines

  1. /* MoonIconView.m
  2.  * Part of the Moon application for the NeXT computer.
  3.  * Author:  Geoffrey S. Knauth
  4.  * Date:    January 4, 1992
  5.  *
  6.  * Permission to copy this program is hereby granted under the terms
  7.  * of the Free Software Foundation's GNU General Public License.
  8.  */
  9.  
  10. #import <dpsclient/psops.h>        /* PSsetgray */
  11. #import "MoonIconView.h"
  12. #import "all.h"
  13.  
  14. @implementation MoonIconView
  15.  
  16. - initFrame :(const NXRect *)frameRect
  17. {
  18.     [super initFrame:frameRect];
  19.     [self setOpaque:YES];
  20.     return self;
  21. }
  22.  
  23. - drawSelf :(const NXRect *)rects :(int)rectCount
  24. {
  25.     NXPoint center = {NX_WIDTH(&bounds)/2., NX_HEIGHT(&bounds)/2.};
  26.     float yradius = NX_HEIGHT(&bounds)/2.-2.;
  27.     float xradius = yradius;
  28.  
  29.     PSsetgray(NX_LTGRAY);
  30.     NXRectFill(&bounds);
  31.  
  32.   /* draw the image of the moon */
  33.     PSsetgray(NX_WHITE);
  34.     PSarc(center.x, center.y, yradius, 0., 360.);
  35.     PSfill();
  36.  
  37.   /* now draw the shadow over that part hidden from the sun */
  38.     DrawMoonShadow([self phase], ¢er, xradius, yradius, NX_BLACK);
  39.  
  40.     return self;
  41. }
  42.  
  43. - (float) phase
  44. {
  45.     return phase;
  46. }
  47.  
  48. - setPhase :(float) val
  49. {
  50.     phase = val;
  51.     return self;
  52. }
  53.  
  54. @end
  55.